function frequency = time_to_frequency(quarter1, quarter2, num)
% This function transforms units of time into frequencies.
%
% INPUT: - one scalar representing quarters of time
%        - or two scalars representing quarters of time and a scalar, num,
%          indicating the number of points in the output vector
%
% OUTPUT: - if one input is provided, it returns the associated frequency
%         - if two inputs are provided, it returns a vector of frequencies
%           between the frequencies associated with quarter1 and quarter2.
%           num specifies the number of points in this vector.
%
% NOTES:
% To obtain an interpretation for frequency in terms of units of time
% rather than radius, relate w to its associated period p (defined as the 
% number of units of time necessary for y_t^w  to compete a cycle): p =
% 2*pi/w. In turn, 1/p = w/(2*pi) indicates the number of cycle completed
% by y_t^w per period.
%
% With a period representing a quarter, a 40 year cycle has an associated
% value of w = 2*pi/40 = 0.157. A 6 year cycle has   w = 2*pi/6 = 1.047.
% Thus, values for w in the range of [0.157, 1.047] are of central interest
% in analyzing bysiness cycle behaviour. More information see Dave and
% DeJong, Structural Macroeconometrics, Chapter 6.2
%
% Christoph Goertz
% 17.04.2012

if nargin == 1
    frequency = 2*pi/quarter1;
elseif nargin == 3
    quarters = linspace(quarter1,quarter2,num);
    frequency = zeros(1,num);
    for iQuarters = 1:num
        frequency(1,iQuarters) = 2*pi/quarters(iQuarters); 
    end
else
    warning('Wrong number of inputs provided');
end

